package com.hhl.lamda.filteranullvaluefromastream;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author HHL
 * @description
 * @date 2018/11/18 - 19:02
 */
public class FilterNullFromStream {

    public static void main(String[] args) {

        Stream<String> language = Stream.of("java", "python", "node", null, "ruby", null, "php");
        List<String> result = language.collect(Collectors.toList());
        result.forEach(System.out::print);
//        java python node null ruby null php
        System.out.println();


        // To solve it, uses Stream.filter(x -> x!=null)
        List<String> result1 = language
                .filter(x -> x != null)
                .collect(Collectors.toList());
        result1.forEach(System.out::print);
        //        java python node ruby php
        System.out.println();






    }
}
